package com.uinnova.product.eam.init.schedule;

import com.binary.framework.bean.annotation.Comment;
import com.uinnova.product.eam.init.schedule.job.StartRotaConfJob;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Comment("启用值班表定时任务配置")
@Configuration
public class StartRotaConfQuartzConfiguration {

    @Value("${start.rota.conf.cron:0 0 0 * * ?}")
    private String startRotaConfCron;

    @Bean
    public JobDetail startRotaConfJob() {
        return JobBuilder.newJob(StartRotaConfJob.class).withIdentity("StartRotaConfJob").storeDurably().build();
    }

    @Bean
    public Trigger startRotaConfJobTrigger(JobDetail startRotaConfJob) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(startRotaConfCron);
        return TriggerBuilder.newTrigger().forJob(startRotaConfJob)
                .withIdentity("StartRotaConfJob").withSchedule(scheduleBuilder).build();
    }

}
